package org.qhhc.singleton;

public class Singleton_lanhan_Double_Checked_Locking {
    // 1. 私有化构造方法
    private Singleton_lanhan_Double_Checked_Locking() {}
    // 2.声明成员变量
    private static volatile Singleton_lanhan_Double_Checked_Locking instance;
    // 3.对外提供
    public static Singleton_lanhan_Double_Checked_Locking getInstance() {
        if (instance == null) {
            synchronized (Singleton_lanhan_Double_Checked_Locking.class) {
                if (instance == null) {
                    instance = new Singleton_lanhan_Double_Checked_Locking();
                }
            }
        }
        return instance;
    }
}
